

import { h } from 'vue'
import { NInput } from 'naive-ui'
import { isFunction } from 'lodash'
import type { IJsonItem } from '../types'

export function renderInput(item: IJsonItem, fields: { [field: string]: any }) {
  const { props, field } = isFunction(item) ? item() : item
  return h(NInput, {
    ...props,
    value: fields[field],
    onUpdateValue: (value: string) => void (fields[field] = value)
  })
}
